/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Server.domain;

import Server.domain.ai.AIType;
import Server.domain.ai.MobAIFactory;
import Server.domain.ai.MobAI;
import java.awt.Color;

/**
 *
 * @author Ripper
 */
public class Mob extends Entity implements WorldOccupant
{
    private String monsterName;
    private int monsterID;
    private int xp;
    private double chanceToDropLoot;
    private int lootDropAmount;
    
    private MobAI ai;
    
    public Mob(GameLevel gl, String mobName, int mobID, int lookType, Color[] colors, int team, int moveSpeed, int hp, double hpregen,
            int baseArmor, int basePhysicalDamage, int baseMagicArmor, int baseMagicDamage,
            double critChance, double critMpr, double lifestealPercentage, double spellvampPercentage,
            AIType ai, int hitbox, int exp, double lootChance, int lootAmount)
    {
        super(gl, mobName, lookType, colors, team, moveSpeed, true, hp, hpregen, 
                baseArmor, basePhysicalDamage, baseMagicArmor, baseMagicDamage, 
                critChance, critMpr, lifestealPercentage, spellvampPercentage, hitbox);
        
        setMonsterID(mobID);
        setMonsterName(mobName);
        setXp(exp);
        setChanceToDropLoot(lootChance);
        setLootDropAmount(lootAmount);
        
        this.ai = MobAIFactory.createAI(ai, this);
    }

    public String getMonsterName() { return monsterName; }
    public final void setMonsterName(String monsterName) { this.monsterName = monsterName; }
    public int getMonsterID() { return monsterID; }
    public final void setMonsterID(int monsterID) { this.monsterID = monsterID; }
    public int getXp() { return xp; }
    public final void setXp(int xp) { this.xp = xp; }
    public double getChanceToDropLoot() { return chanceToDropLoot; }
    public final void setChanceToDropLoot(double chanceToDropLoot) {
        this.chanceToDropLoot = chanceToDropLoot;
    }
    public int getLootDropAmount() { return lootDropAmount; }
    public void setLootDropAmount(int lootDropAmount) {
        this.lootDropAmount = lootDropAmount;
    }


    @Override
    public String getNecessaryInformation()
    {
        return super.getNecessaryInformation() + ",mob_nm:"+getMonsterName()+",mob_id:"+getMonsterID();
    }
    
    @Override
    public String getLocationData()
    {
        return "m_id:"+getMonsterID()+"," + super.getLocationData();
    }
    
    @Override
    public void specificUpdate() 
    {
        //TODO
    }
    
    @Override
    public void think()
    {
        if(ai != null)
        {
            ai.think();
        }
    }
    
    @Override
    public void doSpecificAttack()
    {
        //TODO
    }
    
    @Override
    public void takeTrueDamage(int dmg)
    {
        super.takeTrueDamage(dmg);
        Player attacker = getGamelevel().getCurrentAttacker();
        
        ai.damageTaken(attacker,dmg, attacker.getAggroMultiplier());
        //System.out.println("I, "+getEntityName()+"("+getMonsterID()+"), took "+dmg+" damage!");
    }
}
